import { defineConfig } from 'vitepress';
import { resolve } from 'path';
import { fileURLToPath, URL } from 'node:url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

export default defineConfig({
  title: 'L1n Vue Components',
  description: 'Vue 3 组件库文档 - 现代化的前端组件解决方案',
  
  // 站点配置
  lang: 'zh-CN',
  base: '/',
  
  // Vite 配置
  vite: {
    resolve: {
      alias: {
        '@l1n/vue-components': resolve(__dirname, '../../../packages/vue-components/src/index.ts'),
        '@l1n/utils': resolve(__dirname, '../../../packages/utils/src/index.ts')
      }
    },
    optimizeDeps: {
      exclude: ['@l1n/vue-components', '@l1n/utils']
    }
  },
  
  // 主题配置
  themeConfig: {
    logo: false,
    siteTitle: 'L1n Vue', 
    
    // 顶部导航
    nav: [
      { 
        text: '📖 指南', 
        items: [
          { text: '快速开始', link: '/guide/getting-started' },
          { text: '安装', link: '/guide/installation' },
          { text: '主题配置', link: '/guide/theming' }
        ]
      },
      { 
        text: '🧩 Components', 
        link: '/components/default',
      },
      { 
        text: '🔧 Utils', 
        link: '/utils/',
      },
      { 
        text: '🎯 React 组件', 
        link: 'http://localhost:8000',
        target: '_self'
      },
       { 
        text: '🏠 文档首页', 
        link: 'http://localhost:3000',
        target: '_self'
      },
    ],
    
    // 侧边栏配置
    sidebar: {
      '/guide/': [
        {
          text: '开始使用',
          items: [
            { text: '介绍', link: '/guide/' },
            { text: '快速开始', link: '/guide/getting-started' },
            { text: '安装指南', link: '/guide/installation' },
            { text: '主题配置', link: '/guide/theming' }
          ]
        },
        {
          text: '开发指南',
          items: [
            { text: 'CodeDemo 组件', link: '/guide/code-demo' },
            { text: '自定义主题', link: '/guide/custom-theme' },
            { text: '国际化', link: '/guide/i18n' },
            { text: '最佳实践', link: '/guide/best-practices' }
          ]
        }
      ],
      '/components/': [
        {
          text: '基础组件',
          items: [
            { text: 'Button 按钮', link: '/components/basic/button' },
            { text: 'Icon 图标', link: '/components/basic/icon' },
            { text: 'Typography 排版', link: '/components/basic/typography' }
          ]
        },
        {
          text: '布局组件',
          items: [
            { text: 'Layout 布局', link: '/components/layout/layout' },
            { text: 'Grid 栅格', link: '/components/layout/grid' },
            { text: 'Space 间距', link: '/components/layout/space' }
          ]
        },
        {
          text: '表单组件',
          items: [
            { text: 'Input 输入框', link: '/components/form/input' },
            { text: 'Select 选择器', link: '/components/form/select' },
            { text: 'Checkbox 复选框', link: '/components/form/checkbox' },
            { text: 'Radio 单选框', link: '/components/form/radio' }
          ]
        },
        {
          text: '数据展示',
          items: [
            { text: 'Table 表格', link: '/components/display/table' },
            { text: 'List 列表', link: '/components/display/list' },
            { text: 'Card 卡片', link: '/components/display/card' },
            { text: 'Avatar 头像', link: '/components/display/avatar' }
          ]
        },
        {
          text: '反馈组件',
          items: [
            { text: 'Alert 警告提示', link: '/components/feedback/alert' },
            { text: 'Loading 加载', link: '/components/feedback/loading' },
            { text: 'Message 消息提示', link: '/components/feedback/message' },
            { text: 'Modal 模态框', link: '/components/feedback/modal' }
          ]
        }
      ],
      '/utils/': [
        {
          text: '工具函数',
          items: [
            { text: '概览', link: '/utils/' },
            { text: '日期处理', link: '/utils/date' },
            { text: '数据验证', link: '/utils/validation' },
            { text: '格式化', link: '/utils/format' }
          ]
        }
      ],
      '/api/': [
        {
          text: 'API 参考',
          items: [
            { text: '组件 API', link: '/api/components' },
            { text: '工具 API', link: '/api/utils' },
            { text: '类型定义', link: '/api/types' }
          ]
        }
      ]
    },
    
    // 页脚配置
    footer: {
      message: 'L1n Vue Components - 基于 Vue 3 的现代组件库',
      copyright: 'Copyright © 2024 L1n UI Library. Made with ❤️'
    },
    
    // 编辑链接
    editLink: {
      pattern: 'https://github.com/your-org/l1n-ui/edit/main/docs/vue-docs/:path',
      text: '在 GitHub 上编辑此页面'
    },
    
    // 搜索配置
    search: {
      provider: 'local'
    },
    
    // 大纲配置
    outline: {
      level: [2, 3],
      label: '页面导航'
    }
  },

  
  // Markdown 配置
  markdown: {
    lineNumbers: false, // 禁用代码块行号显示
    theme: {
      light: 'github-light',
      dark: 'github-dark'
    }
  }
});